package com.mapler.mayzus.service;

import com.mapler.model.AdModel;
import com.mapler.model.SModel;
import com.mapler.model.UAModel;
import com.mapler.service.INotifier;
import com.mapler.service.ITask;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import org.apache.log4j.Logger;

/**
 *
 * @author none
 */
public class MayzusPostWorker implements ITask{
    public ScheduledExecutorService executor =  Executors.newScheduledThreadPool(10);
    private SModel sModel;
    private ArrayList<UAModel> uaModels;
    ArrayList<AdModel> addModels;
    private HashMap<String,UAModel> usHashMap;
    private static Logger log = Logger.getLogger(MayzusPostWorker.class);
    private INotifier iNotifier;
    public MayzusPostWorker(INotifier iNotifier,SModel sModel,ArrayList<UAModel> uaModels,ArrayList<AdModel> 
            addModels,HashMap<String,UAModel> usHashMap){
        this.sModel = sModel;
        this.uaModels = uaModels;
        this.addModels = addModels;
        this.usHashMap = usHashMap;
        this.iNotifier = iNotifier;
    }
    @Override
    public void update() {
        try {
            iNotifier.notify("Post:: Going to start working.");
            executor.execute(new MayzusPostClick(iNotifier,this.sModel,this.uaModels,this.addModels,usHashMap)); 
        } catch (Throwable ex) {
            ex.printStackTrace();
            log.debug("Post:: Error "+ex);
        }
    }

    @Override
    public void finish() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
